package cate.game.play.skill.active;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.effect.SkillEffect;

/**
 * 对敌方全体进行天威审判，50%概率使其受到一次天威伤害（攻击45%+天威标记数*15%）并增加1层天威标记，天威伤害上限为120%标记无法被净化
 */
public class 天威审判AH extends ActiveHandler{

	private int 概率;

	private String buff标签;

	private double 系数;

	private double 上限;

	//概率=5000&buff标签=天威标记&系数=1500&上限=12000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff标签 = args.get("buff标签");
		系数 = args.getDouble("系数", 0d);
		上限 = args.getDouble("上限", 0d);
	}

	@Override
	public void afterSelectTargets(SkillActionCtx action, SkillEffect effect) {
		for (Fighter target : action.getTargets()) {
			if (!XT.chance(概率)) {
				effect.getTargetCtx(target).setForceMiss(true);
			} else {
				int buffNum = target.buff.countBuffByTag(buff标签);
				double exCoeff = Math.max(系数 * buffNum, 上限);
				effect.getTargetCtx(target.getPid()).addHpCfgByCoeff(exCoeff);
			}
		}
	}
}
